<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> History </title>
  <meta http-equiv="content-type" content="text/html,no-cache; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Latest compiled and minified CSS -->
  
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
 </head>
<script language="Javascript">
var ccontrol=true;
function CheckForm(transThis, form_name)
{
	if(transThis.value == "delete"){
		  if(confirm("delete order ?")==true) {
			  ccontrol=true;
			  document.getElementById(form_name).submit();

		  } else {
			  ccontrol=false;
		    return false;
		  }
	}
	document.getElementById(form_name).submit();
}
function CheckSubmit(){
	return ccontrol;
}
</script>

 <body>
 <div class="navbar navbar-inverse navbar-fixed-top" >
	<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target=".navbar-collapse">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">Phimpme </a> 
			</div>


       <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li><a href="/">GenApp</a></li>

			<li  class="active">
				<a href='/cgi-bin/orders/review'>Orders</a> 
			</li>       
			
			<li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
			{% if user %}
			</ul>
			<ul  class="nav navbar-nav navbar-right" >
			<li>
				<a href='/cgi-bin/usermgt/changepwd/'>Welcome {{ user }}</a>
			</li>
			<li>
				<a href='/cgi-bin/usermgt/logout/'>Log out</a>
			</li>
			</ul>
			{% else %}
 			</ul>
			
 
          <form class="navbar-form navbar-right" role="form"  action='/cgi-bin/usermgt/login/' method = 'POST' >
            <div class="form-group">
              <input type="text" placeholder="Email" class="form-control">
            </div>
            <div class="form-group">
              <input type="password" placeholder="Password" class="form-control">
            </div>
            <button type="submit" class="btn btn-success">Sign in</button>
          </form>
          
          {% endif %}
          
		</div>
			
		</div>
	</div>
<!--  <ul>
<a style="display: block;float: left;" href='/cgi-bin/usermgt/logout/' >Log out</a><a style="display: block;float: right;" href='/' >Configure new</a>
</ul>
</br></br></br></br>
</div> -->

</br></br></br></br>
	 <DIV class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-1 main">
		<H1 class="sub-header">Order List</H1>
	<div id="renovateTable" class="table-responsive">
	<table class = "table table-striped">
	<tr><td width='25px'>Id</td>
	<td width='150ppx'>Created time</td>
	<td width='150ppx'>Due time</td>
	<td width='100px'> App Name </td>
	<td width='100px' >Package</td>
	<td width='50px'> Price </td><td width='150ppx'> Status </td><td width='220px'>Operation </td></tr>
	</table>
	{% for obj in all_order %}
	<form action='/cgi-bin/orders/history/' id='form{{obj.id}}' method = 'POST' onSubmit="return CheckSubmit();" >
	<table class="table table-striped">
	<tr>
		<td width='20px'><input style="width:20px;text-align:center;" name='id' value='{{ obj.id }}' readonly='readonly' ></iput></td>
		<td width='150px'>{{ obj.order_created_time }}</td>
		<td width='150ppx'>{{ obj.order_due_time }}</td>
		<td width='100px'>{{ obj.order_appname }}</td>
		<td width='100px'>{{ obj.order_package }}</td>
		<td width='50px'>{{ obj.order_values }}</td>
		<td width='150ppx'>
		{% if obj.order_status == 3 %}
		Regenerate Success
		{% elif obj.order_status == 2 %}
		Generate Success
		{% elif obj.order_status == 4 %}
		Generate Failed(Pay Success)
		{% elif obj.order_status == 0 %}
		Waiting Payment
		{% else %}
		Building...
		{% endif %}
		</td>	
		<td width='220px'>{% if obj.order_status == 3 %}
		<input  id ='delete'  class="btn btn-sm btn-danger" type="submit" name='operation' value='Delete' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		<input id ='download'  class="btn btn-sm btn-primary" type="submit" name='operation' value='Download' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		{% elif obj.order_status == 2 %}
		<input  class="btn btn-sm btn-info" id ='reconf' type="submit" name='operation' value='Reconf' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		<input  id ='delete' class="btn btn-sm btn-danger" type="submit" name='operation' value='Delete' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		<input id ='download'  class="btn btn-sm btn-primary" type="submit" name='operation' value='Download' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		{% elif  obj.order_status == 0 %}
		<input id ='pay'  class="btn btn-sm btn-primary" type="submit" name='operation' value='Pay' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		<input  id ='delete' class="btn btn-sm btn-danger" type="submit" name='operation' value='Delete' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		{% elif obj.order_status == 4 %}
		<input id ='rebuild'  class="btn btn-sm btn-primary" type="submit" name='operation' value='Rebuild' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		<input  id ='delete' class="btn btn-sm btn-danger" type="submit" name='operation' value='Delete' onclick="CheckForm(this, 'form{{ obj.id }}');"></input>
		{% else %}
		<a>just waiting</a>
		{% endif %}
		</td>
		</tr>
	</table>
	</form>
	{% endfor %}
	</div>
 </body>
</html>
